package com.ruoze.bdp.utils;

import com.ruoze.bdp.enums.ExceptionEnum;
import com.ruoze.bdp.commons.ResponseDto;


public class ResponseUtil {
    public static <T>ResponseDto<T> successData(T t){
        ResponseDto responseDto = new ResponseDto<>(ExceptionEnum.SUCCESS.getCode(), ExceptionEnum.SUCCESS.getMsg());
        responseDto.setData(t);
        return responseDto;
    }
    public static ResponseDto successData(String code, String msg){
        ResponseDto responseDto = new ResponseDto<>(code, msg);
        responseDto.setData(null);
        return responseDto;
    }

    public static ResponseDto fail(String errorCode, String errorMessage){
        ResponseDto responseDto = new ResponseDto<>(errorCode, errorMessage);
        responseDto.setData(null);
        return responseDto;
    }

    public static ResponseDto fail(String errorMessage){
        ResponseDto responseDto = new ResponseDto<>(errorMessage);
        responseDto.setData(null);
        return responseDto;
    }
}
